package com.shxzz.easy12306.framework.starter.convention.exceptions;

import com.shxzz.easy12306.framework.starter.convention.errorcode.BaseErrorCode;
import com.shxzz.easy12306.framework.starter.convention.errorcode.ErrorCode;

import java.io.Serial;

/**
 * 服务端异常
 * @author shxzz
 * @create 2024-01-25-22:31
 */
public class ServiceException extends AbstractException {
    @Serial
    private static final long serialVersionUID = 3423939537554536275L;

    public ServiceException(String errorMsg) {
        this(errorMsg, null, BaseErrorCode.SERVICE_ERROR);
    }

    public ServiceException(ErrorCode errorCode) {
        this(null, null, errorCode);
    }

    public ServiceException(Throwable throwable, ErrorCode errorCode) {
        this(null, throwable, errorCode);
    }

    public ServiceException(String errorMsg, Throwable throwable, ErrorCode errorCode) {
        super(errorMsg, throwable, errorCode);
    }

    @Override
    public String toString() {
        return "ServiceException{" +
                "code='" + errorCode + "'," +
                "message='" + errorMsg + "'" +
                '}';
    }
}
